import json
import unittest
import ddt

from Auto_excelInterfaceTest.base_data.base_data import BaseMethod
from Auto_excelInterfaceTest.common_utils.commons import Common

r = Common().ReadExcelTypeDict('testCase.xlsx')


@ddt.ddt
class loginTest(unittest.TestCase):
    # def setUp(self):
    #     self.logs = Common().get_logs()
    #     self.logs.debug('开始写入本条用例')
    #
    # def tearDown(self):
    #     self.logs.debug('本条用例结束')

    @ddt.data(*r)
    def test_login(self, pars):
        '''登录验证'''
        dic = json.loads(pars['data参数值'])
        url = pars['接口地址']
        yuqi = pars['预期结果']
        req = pars['请求方式']
        result = BaseMethod().requests_type(method=req, url=url, data=dic)
        self.assertEqual(result.text, yuqi)


if __name__ == "__main__":
    loginTest().test_login

